home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Dev / SpeakFreely_Src / gsm / src / code.c < prev    next >
C/C++ Source or Header  |  2000-05-27  |  3KB  |  101 lines

  1. /*
  2.  * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
  3.  * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
  4.  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  5.  */
  6.  
  7. /* $Header: /home/kbs/jutta/src/gsm/gsm-1.0/src/RCS/code.c,v 1.1 1992/10/28 00:15:50 jutta Exp $ */
  8.  
  9. #include    "config.h"
  10.  
  11.  
  12. #ifdef    HAS_STDLIB_H
  13. #include    <stdlib.h>
  14. #else
  15. #    include "proto.h"
  16.     extern char    * memcpy P((char *, char *, int));
  17. #endif
  18.  
  19. #include    "private.h"
  20. #include    "gsm.h"
  21. #include    "proto.h"
  22.  
  23. /* 
  24.  *  4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER 
  25.  */
  26.  
  27. void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),
  28.  
  29.     struct gsm_state    * S,
  30.  
  31.     word    * s,    /* [0..159] samples              IN    */
  32.  
  33. /*
  34.  * The RPE-LTD coder works on a frame by frame basis.  The length of
  35.  * the frame is equal to 160 samples.  Some computations are done
  36.  * once per frame to produce at the output of the coder the
  37.  * LARc[1..8] parameters which are the coded LAR coefficients and 
  38.  * also to realize the inverse filtering operation for the entire
  39.  * frame (160 samples of signal d[0..159]).  These parts produce at
  40.  * the output of the coder:
  41.  */
  42.  
  43.     word    * LARc,    /* [0..7] LAR coefficients        OUT    */
  44.  
  45. /*
  46.  * Procedure 4.2.11 to 4.2.18 are to be executed four times per
  47.  * frame.  That means once for each sub-segment RPE-LTP analysis of
  48.  * 40 samples.  These parts produce at the output of the coder:
  49.  */
  50.  
  51.     word    * Nc,    /* [0..3] LTP lag            OUT     */
  52.     word    * bc,    /* [0..3] coded LTP gain        OUT     */
  53.     word    * Mc,    /* [0..3] RPE grid selection        OUT     */
  54.     word    * xmaxc,/* [0..3] Coded maximum amplitude    OUT    */
  55.     word    * xMc    /* [13*4] normalized RPE samples    OUT    */
  56. )
  57. {
  58.     int    k;
  59.     word    * dp  = S->dp0 + 120;    /* [ -120...-1 ] */
  60.     word    * dpp = dp;        /* [ 0...39 ]     */
  61.  
  62.     word        ep[40];
  63.     static word    e [50] = {0};
  64.  
  65.     word    so[160];
  66.  
  67.     Gsm_Preprocess            (S, s, so);
  68.     Gsm_LPC_Analysis        (S, so, LARc);
  69.     Gsm_Short_Term_Analysis_Filter    (S, LARc, so);
  70.  
  71.     for (k = 0; k <= 3; k++, xMc += 13) {
  72.  
  73.         Gsm_Long_Term_Predictor    ( S,
  74.                      so+k*40, /* d      [0..39] IN    */
  75.                      dp,      /* dp  [-120..-1] IN    */
  76.                     e + 5,      /* e      [0..39] OUT    */
  77.                     dpp,      /* dpp    [0..39] OUT */
  78.                      Nc++,
  79.                      bc++);
  80.  
  81.         Gsm_RPE_Encoding    ( S,
  82.                     e + 5,    /* e      ][0..39][ IN/OUT */
  83.                       xmaxc++, Mc++, xMc );
  84.         /*
  85.          * Gsm_Update_of_reconstructed_short_time_residual_signal
  86.          *            ( dpp, e + 5, dp );
  87.          */
  88.  
  89.         { register int i;
  90.           register longword ltmp;
  91.           for (i = 0; i <= 39; i++)
  92.             dp[ i ] = GSM_ADD( e[5 + i], dpp[i] );
  93.         }
  94.         dp  += 40;
  95.         dpp += 40;
  96.  
  97.     }
  98.     (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
  99.         120 * sizeof(*S->dp0) );
  100. }
  101.